package com.nkbh.sevenday.myimagethreadpool.activity;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.GridView;

import com.nkbh.sevenday.myimagethreadpool.R;
import com.nkbh.sevenday.myimagethreadpool.adapter.Images;
import com.nkbh.sevenday.myimagethreadpool.adapter.PhotoWallAdapter;

public class GridViewImageActivity extends AppCompatActivity {

    GridView gv;

    /**
     * GridView的适配器
     */
    private PhotoWallAdapter adapter;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_grid_view_image);
        initView();
    }

    private void initView() {
        gv=findViewById(R.id.photo_wall);
        adapter=new PhotoWallAdapter(this, 0, Images.imageThumbUrls, gv);
        gv.setAdapter(adapter);
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        // 退出程序时结束所有的下载任务
        adapter.cancelAllTasks();
    }
}
